package table.creators;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import controllers.AuthorHelper;
import models.Check_work;
import models.Customer;
import models.Driver;
import models.Vehicle;
import controllers.Helper;
import controllers.TableModel;
import controllers.TableModel.AoColum;

public class Check_workTable {

    public static TableModel create(String current_user) {
    
        final String title = "司机考勤";
        String today = Helper.dateToString(new Date());
        String now = Helper.datetimeToString(new Date());

        List<AoColum> colums = new ArrayList<AoColum>();
        TableModel model = new TableModel();

        //                           name,             title,         required,     defaut,        cansearch, editable,    edit_type,    edit_data,            editable_settings    
        if(true) {
           colums.add(model.new AoColum("id",    "编号",    false,    "",    false,    false,    "select",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("drive_time",    "用车时间",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("customer.name",    "用车客户",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Customer.getNameJson(),    null,  "ONEBOX",  "customer",  "name",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("road_line",    "计划行程",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("driver.name",    "司机",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Driver.getNameJson(),    null,  "ONEBOX",  "driver",  "name",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("vehicle.plate_number",    "车号",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Vehicle.getPlate_numberJson(),    null,  "ONEBOX",  "vehicle",  "plate_number",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("check_time",    "核定数（小时）",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        model.buildModel(Check_work.class, 600, title, AuthorHelper.canDo(current_user, title, "增加"), AuthorHelper.canDo(current_user, title, "搜索"), AuthorHelper.canDo(current_user, title, "删除"), colums);
        return model;
    }
}

